function displayInfo(item) {
	$.ajax({
		url: "infouser",
		type: "post",
		data: {login:[item]},
		dataType: "json",
		success: function(user) {
			client = user;
			$("#info-user").html(user.nom + " " + user.prenom + " - Solde : " + user.solde + "€");
			$("#solde-final").html(user.solde + "€");
			updateSolde($('#montant').val());
		},
		error: function(e,xhr) {
			alert("Cet utilisateur n'existe pas.");
		}
	});
}

function removeInfo() {
	$("#info-user").html("");
	$("#solde-final").html("");
	client = null;
}

function updateSolde(val) {
	if(typeof(client) != 'undefined' && client != null) {
		if(!$.isNumeric(val)) {
			var solde = client.solde;
			$('#currency').html("<img style='width:16 px; height: 16px' src='/css/main/images/icons/cross.png'/>");
		} else {
			var solde = parseFloat(client.solde) + parseFloat(val);
			solde = solde.toFixed(2);
			$('#currency').html("€");
		}
		$("#solde-final").html(solde + "€");
	}
	if(solde < 0) {
		$("#solde-final").css("color", "red");
	} else {
		$("#solde-final").css("color", "white");
	}
}